<?php
/**
 * 
 * Helper for "app" links within Abovo
 * 
 * Creates a link from app class to module/app. For example:
 * `Abovo_App_Crm_Companies`  becomes a href to crm/companies.
 * 
 * @category Abovo
 * 
 * @package Abovo_View_Helper
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 * 
 */

/**
 * 
 * Helper for "app" links within Abovo
 * 
 * @category Abovo
 * 
 * @package Abovo_View_Helper
 * 
 */
class Abovo_View_Helper_AppAction extends Solar_View_Helper {
    
    /**
     * 
     * Creates a link from class name
     * 
     * @param string $class App's class name
     * 
     * @param string|null Text for the <a> tag if not null
     * 
     * @return string Href spec or a full <a></a> XHTML tag
     * 
     */
    public function appAction($class, $text = null)
    {
        $parts = explode('_', $class);
        $link = implode('/', array_slice($parts, -2, 2));
        
        return $this->_view->action(strtolower($link), $text);
    }
}
